<!DOCTYPE html>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/mytags.jsp"%>
<title>合同签订</title>
<t:base type="jquery,my97,easyui,dataTables,idtabs,lhgdialog"></t:base>
<%@ include file="/jsp/common/common_script.jsp"%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<!-- extend -->
<!-- 模块js文件 -->
<script type="text/javascript">
//初始化列表
var initGrid = function(){
	$('#bankTable').dataTable({
		"bProcessing" : true, //DataTables载入数据时，是否显示‘进度’提示
        "bServerSide" : true, //是否启动服务器端数据导入
        "bStateSave" : false, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态
        "bJQueryUI" : true, //是否使用 jQury的UI theme
        "aLengthMenu" : [5, 10, 15], //更改显示记录数选项
        "iDisplayLength" : 5, //默认显示的记录数
        "bAutoWidth" : true, //是否自适应宽度 update\
        "bScrollCollapse" : false, //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变
        "bPaginate" : false, //是否显示（应用）分页器
        "bInfo" : false, //是否显示页脚信息，DataTables插件左下角显示记录数
        "sPaginationType" : "full_numbers", //详细分页组，可以支持直接跳转到某页
        "bSort" : false, //是否启动各个字段的排序功能
        "aaSorting" : [[1, "ASC"]], //默认的排序方式，第3列，升序排列
        "bFilter" : false, //是否启动过滤、搜索功能
        "sPaginationType": "full_numbers",
	    "sAjaxSource":"loan/ContractManage/findBankListByLoanId",
        "fnServerData":retrieveData,  //自定义数据获取函数
        
		"aoColumns" : [{
			"mDataProp" : "bankAccount",
			"sTitle" : "账户名",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		},{
			//Client_Bank_Type_Code
			"mDataProp" : "bankType",
			"sTitle" : "银行卡类型",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return top.SYS_BASE_DATA['Client_Bank_Type_Code'][data];
			}
		}, {
			//Client_Bank_Name_Code
			"mDataProp" : "bankName",
			"sTitle" : "银行名称",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return top.SYS_BASE_DATA['Client_Bank_Name_Code'][data];
			}
		}, {
			"mDataProp" : "bankBranch",
			"sTitle" : "银行所属分行",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		}, {
			"mDataProp" : "bankNumber",
			"sTitle" : "银行帐号",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		}, {
			//Client_Bank_Main_Status_Code
			"mDataProp" : "bankMainStatus",
			"sTitle" : "是否为主帐号",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				return top.SYS_BASE_DATA['Client_Bank_Main_Status_Code'][data];
			}
		}
		
		],
		"oLanguage": {
            "sUrl":"static_resources/language/lang-cn.txt" //这个是国际化，也就是汉化的各种文字数据源，写对url就行了
        }
	});
	
	$('#guaranteeTable').dataTable({
		"bProcessing" : true, //DataTables载入数据时，是否显示‘进度’提示
        "bServerSide" : true, //是否启动服务器端数据导入
        "bStateSave" : false, //是否打开客户端状态记录功能,此功能在ajax刷新纪录的时候不会将个性化设定回复为初始化状态
        "bJQueryUI" : true, //是否使用 jQury的UI theme
        "aLengthMenu" : [5, 10, 15], //更改显示记录数选项
        "iDisplayLength" : 5, //默认显示的记录数
        "bAutoWidth" : true, //是否自适应宽度 update\
        "bScrollCollapse" : false, //是否开启DataTables的高度自适应，当数据条数不够分页数据条数的时候，插件高度是否随数据条数而改变
        "bPaginate" : true, //是否显示（应用）分页器
        "bInfo" : true, //是否显示页脚信息，DataTables插件左下角显示记录数
        "sPaginationType" : "full_numbers", //详细分页组，可以支持直接跳转到某页
        "bSort" : true, //是否启动各个字段的排序功能
        "aaSorting" : [[0, "ASC"]], //默认的排序方式，第3列，升序排列
        "bFilter" : false, //是否启动过滤、搜索功能
	    "sAjaxSource":"sys/LoanGuarantee/list",
        "fnServerData":retrieveData,  //自定义数据获取函数
		"aoColumns" : [ {
			"mDataProp" : "id",
			"sTitle" : "序号",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center"
		},
		  {
			"mDataProp" : "",
			"sTitle" : "操作",
			"bSortable": false,
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
		      var id = row.id;
		      var parseStr = '<a href="javascript:showBankInfo('+id+');" class="tablelink">查看</a>&nbsp;';
		      return parseStr;
		    }
			
		}, {
			"mDataProp" : "guaranteeMode",
			"sTitle" : "担保方式",
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				  if(!data){
					  return "";
				  }
			      return top.SYS_BASE_DATA['Loan_Guarantee_Mode_Code'][data];
				}
		}, {
			"mDataProp" : "guaranteeType",
			"sTitle" : "抵押物类型",
			"sDefaultContent" : "",
			"sClass" : "center",
			"mRender": function (data, display, row) {
				  if(!data){
					  return "";
				  }
			      return top.SYS_BASE_DATA['Loan_Guarantee_Type_Code'][data];
				}
		}, {
			"mDataProp" : "guaranteeGoods",
			"sTitle" : "物品名称/公司名",
			"sDefaultContent" : "",
			"sClass" : "center"
		}, {
			"mDataProp" : "guaranteePossessor",
			"sTitle" : "所有权人名称",
			"sDefaultContent" : "",
			"sClass" : "center"
		}
		
		],
		"oLanguage": {
            "sUrl":"static_resources/language/lang-cn.txt" //这个是国际化，也就是汉化的各种文字数据源，写对url就行了
        }
        
	});
};


//初始化详情信息
var initPage = function(){
	//给贷款信息页面赋值
	_set_lable_text('#_loan_detail span','name','sys/Loan/findByPk?pks=${param.loanId}',false);
	//给合同页面赋值
	_set_lable_text('#_contract_detail span','name','loan/ContractManage/findLoanContractByLoanId?loanId=${param.loanId}',false);
	//给放款页面赋值
	_set_lable_text('#_pay_detail span','name','loan/ContractManage/findLoanPayByLoanId?loanId=${param.loanId}',false);
};



//自定义数据获取函数
var retrieveData = function( sSource, aoData, fnCallback ) {
    aoData.push({'name':'beanProxy[loanId]','value':'${param.loanId}'});  
        $.ajax( {
                type: "POST", 
                url: sSource, 
                cache : false,
                dataType : "json",
	                data : aoData, 
	                success: function(resp) {
	                	if(resp && resp.state == 200){
	                		fnCallback(resp.datagrid);
	                		return false;
	                	}
	                	fnCallback(null);
	            }
	        });
};

//查看担保信息
var showBankInfo = function (id){
	var aData = $('#guaranteeTable').dataTable().fnGetData();
	$.each(aData,function(index,node){
		if(node.id==id){
			_set_default_lable_text('',false,node);
			return;
		}
	});
};

//合同上传
var contract_loading = function(id,clientId){
	$.dialog.confirm('如果合同已经上传，将会被覆盖，确定吗？', function(){
		$.dialog({
			id:'loan_contract_accessory_upload_dailog',
			title:'上传合同附件',
			lock:true,
			width:700,
			height:400,
			content:'url:'+parent.basePath+'jsp/loan/loan_contract_accessory_upload.jsp?loanId='+id+'&clientId='+clientId,
			//data:{'loadId':id,'clientId':clientId},
			close: function(){
				//$('#contractTable').dataTable().fnDraw();
		    }
		});
	});
};

//合同签订
var signContract = function(){
	var contractId = '${param.contractId}',loanId='${param.loanId}',clientId='${param.clientId}',contractAuditRemark=$('#contractAuditRemark').val();
	//alert(contractAuditRemark);
	//return false;
	$.dialog.confirm('确定签订合同吗？', function(){
		 $.ajax( {
             type: "POST", 
             url: 'sys/LoanExt/signContract', 
             cache : false,
             dataType : "json",
	         data : {loanId:loanId,clientId:clientId,id:contractId,contractAuditRemark:contractAuditRemark}, 
	         success: function(resp) {
	                 if(resp && resp.state == 200){
	                	 $.dialog.alert('签订合同成功!',function(){
	                		 top._do_goto_right('jsp/loan/loan_contract_list.jsp');
	                	 });
	                  }else{
	                	  $.dialog.alert('签订合同失败!');
	                  }
	                	
	            }
	        });
	});
};

//退回到审批
var rebackToApproval = function(){
	var loanId='${param.loanId}';
	//alert(contractAuditRemark);
	//return false;
	$.dialog.confirm('确定退回到审批吗？', function(){
		 $.ajax( {
             type: "POST", 
             url: 'sys/LoanExt/constantsBackToApproval', 
             cache : false,
             dataType : "json",
	         data : {pks:loanId}, 
	         success: function(resp) {
	                 if(resp && resp.state == 200){
	                	 $.dialog.alert('退回成功!',function(){
	                		 top._do_goto_right('jsp/loan/loan_contract_list.jsp');
	                	 });
	                  }else{
	                	  $.dialog.alert('退回失败!');
	                  }
	                	
	            }
	        });
	});
};

//合同退回 backToloanContract
//退回到审批
var backToloanContract = function(){
	var loanId='${param.loanId}';
	//alert(contractAuditRemark);
	//return false;
	$.dialog.confirm('退回合同到待申请吗？', function(){
		 $.ajax( {
             type: "POST", 
             url: 'sys/LoanExt/backToloanContract', 
             cache : false,
             dataType : "json",
	         data : {pks:loanId}, 
	         success: function(resp) {
	                 if(resp && resp.state == 200){
	                	 $.dialog.alert('退回合同到待申请成功!',function(){
	                		 top._do_goto_right('jsp/loan/loan_contract_list.jsp');
	                	 });
	                  }else{
	                	  $.dialog.alert('退回合同到待申请失败!');
	                  }
	                	
	            }
	        });
	});
};

$(function(){
	$("#usual1 ul").idTabs();
	//给贷款详情页面赋值
	initPage();
	initGrid();
	
});
</script>
</head>

<body>

	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
	    <li><a href="javascript:void(0)">首页</a></li>
	    <li><a href="javascript:void(0)">贷款管理</a></li>
	    <li><a href="javascript:void(0)">贷款发放</a></li>
	    <li><a href="javascript:void(0)">合同详情</a></li>
    </ul>
    </div>
    
    <div class="formbody">
    	<div id="usual1" class="usual">	
	    	<div class="itab" id="itab">
				<ul>
					<li><a href="#tab1" class="selected">贷款信息</a></li>
					<li><a href="#tab3">放款信息</a></li>
					<li><a href="#tab4">银行账户信息</a></li>
					<li><a href="#tab5">担保信息</a></li>
					<li><a href="#tab2">合同签订</a></li>
				</ul>
			</div>
			
			<div id="tab1" class="tabson">
			 <div class="formbody">
				<div class="formtitle"><span>贷款基本信息</span></div>
				<form id="_loan_detail" name="">
				    <ul class="forminfo">
				    	<li>
				    		<table class="newtablelist" id="">
						        <tbody>
							        <tr>
								        <td class="newtd">贷款申请号</td>
								        <td colspan="5"><span name="loanCode"></span>&nbsp;</td>
								    </tr>
								    <tr>
								        <td class="newtd">贷款人</td>
								        <td><span name="loanBorrower"></span>&nbsp;</td>
								        <td class="newtd">身份证号</td>
								        <td><span name="clientCardId"></span>&nbsp;</td>
								        <td class="newtd">申请日期</td>
								        <td><span name="loanApplyDate@[yyyy-MM-dd]"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">来源渠道</td>
								        <td><span name="loanSource@Loan_Source_Code"></span>&nbsp;</td>
								        <td class="newtd">贷款类型</td>
								        <td><span name="loanType@Loan_Type_Code"></span>&nbsp;</td>
								        <td class="newtd">贷款产品</td>
								        <td><span name="loanProduct@Loan_Product_Code"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">业务性质</td>
								        <td><span name="loanNatureBusiness@Loan_Nature_Business_Code"></span>&nbsp;</td>
								        <td class="newtd">客户性质</td>
								        <td><span name="loanNatureClilent@Loan_Nature_Clilent_Code"></span>&nbsp;</td>
								        <td class="newtd">资金性质</td>
								        <td><span name="loanNatureFund@Loan_Nature_Fund_Code"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">贷款用途</td>
								        <td><span name="loanPurpose@Loan_Purpose_Code"></span>&nbsp;</td>
								        <td class="newtd">申请额度（元）</td>
								        <td><span name="loanLimitApply"></span>&nbsp;</td>
								        <td class="newtd">贷款期限（月）</td>
								        <td><span name="loanDeadlineApply"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">月利率（%）</td>
								        <td><span name="loanRateInterest"></span>&nbsp;</td>
								        <td class="newtd">管理费率（%）</td>
								        <td><span name="loanRateManage"></span>&nbsp;</td>
								        <td class="newtd">手续费率（%）</td>
								        <td><span name="loanRateHandling"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">还款方式</td>
								        <td><span name="loanRepayType@Loan_Repay_Type_Code"></span>&nbsp;</td>
								        <td class="newtd">终审额度（元）</td>
								        <td><span name="finalLimit"></span>&nbsp;</td>
								        <td class="newtd">终审期限（月）</td>
								        <td><span name="finalDeadline"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        <td class="newtd">终审月利率（%）</td>
								        <td><span name="finalRate"></span>&nbsp;</td>
								        <td class="newtd">终审管理费率（%）</td>
								        <td><span name="finalRateManage"></span>&nbsp;</td>
								        <td class="newtd">终审手续费率（%）</td>
								        <td><span name="finalRateHandling"></span>&nbsp;</td>
							        </tr>
							        <tr>
								        
								        <td class="newtd">贷款对象</td>
								        <td><span name="loanObject@Loan_Object_Code"></span>&nbsp;</td>
								        <td class="newtd">项目来源人</td>
								        <td colspan="3"><span name="loanSourceName"></span>&nbsp;</td>
							        </tr>
				    			</tbody>
				    		</table>
				    	</li>
				    </ul>
			    </form>
			</div>
			</div>
			
			
			
			<div id="tab3" class="tabson">
				<div class="formbody">
					<div class="formtitle"><span>放款信息</span></div>
			    	<div class="toolsli">
						<form id="_pay_detail" name="_pay_detail" enctype="multipart/form-data" method="post">
							<input type="hidden" name="id" id="payId"  value=""/>
			    			<ul class="forminfo">
			    				<li>
			    					<table class="newtablelist" id="">
								        <tbody>
									       
										    <tr>
										        <td class="newtd">批核放款金额（元）</td>
										        <td><span name="payMoney"></span>&nbsp;</td>
										        <td class="newtd">实际付款金额（元）</td>
										        <td><span name="payMoneyReal"></span>&nbsp;</td>
										        <td class="newtd">手续费（元）</td>
										        <td><span name="payHf"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">调查费（元）</td>
										        <td><span name="payIf"></span>&nbsp;</td>
										        <td class="newtd">管理费（元）</td>
										        <td><span name="payMf"></span>&nbsp;</td>
										        <td class="newtd">预收首期利息（元）</td>
										        <td><span name="payAdvInterest"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">放款日期</td>
										        <td><span name="payDate@[yyyy-MM-dd]"></span>&nbsp;</td>
										        <td class="newtd">起息日期</td>
										        <td><span name="interestStartTime@[yyyy-MM-dd]"></span>&nbsp;</td>
										        <td class="newtd">结息日期</td>
										        <td><span name="interestEndTime@[yyyy-MM-dd]"></span>&nbsp;</td>
									        </tr>
									         <tr>
										        <td class="newtd">结算日</td>
										        <td colspan="5"><span name="payClearingDay"></span>&nbsp;</td>
										    </tr>
										    <tr>
										        <td class="newtd">备注</td>
										        <td colspan="5"><span name="payRemark"></span>&nbsp;</td>
										    </tr>
			    						</tbody>
			    					</table>
			    				</li>
			  	 			</ul>
			   			</form>
				    </div>
				</div>
			</div>
			
			<div id="tab4" class="tabson">
				<div class="formbody">
					<div class="formtitle"><span>客户银行账户信息</span></div>
					<div class="toolsli">
				 		<table cellpadding="0" cellspacing="0" border="0" class="tablelist"  id="bankTable"></table>
					</div>
				</div>
			</div>
			
			<div id="tab5" class="tabson">
				<div class="formbody">
					<div class="formtitle"><span>担保信息列表</span></div>
			    	<div class="toolsli">
						<table cellpadding="0" cellspacing="0" border="0" class="tablelist" id="guaranteeTable"></table>	
					</div>
					
					<div class="formtitle"><span>担保信息详情</span></div>
					<div class="toolsli">
					    <form id="" name="" enctype="multipart/form-data" method="post">
						    <ul class="forminfo">
						    	<li>
			    					<table class="newtablelist" id="">
								        <tbody>
										    <tr>
										        <td class="newtd">担保方式</td>
										        <td><span name="guaranteeMode@Loan_Guarantee_Mode_Code"></span>&nbsp;</td>
										        <td class="newtd">抵押物类型</td>
										        <td><span name="guaranteeType@Loan_Guarantee_Type_Code"></span>&nbsp;</td>
										        <td class="newtd">物品名称/公司名</td>
										        <td><span name="guaranteeGoods"></span>&nbsp;</td>
									        </tr>
										    <tr>
										        <td class="newtd">评估价值/关系</td>
										        <td><span name="guaranteePrice"></span>&nbsp;</td>
										        <td class="newtd">住址/地址</td>
										        <td colspan="3"><span name="guaranteeAddress"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">数量</td>
										        <td><span name="guaranteeNumber"></span>&nbsp;</td>
										        <td class="newtd">计量单位</td>
										        <td><span name="guaranteeUnit"></span>&nbsp;</td>
										        <td class="newtd">产权证编号</td>
										        <td><span name="guaranteeProperty"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">所有权人名称</td>
										        <td><span name="guaranteePossessor"></span>&nbsp;</td>
										        <td class="newtd">权利人占比（%）</td>
										        <td colspan="3"><span name="guaranteeScale"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">描述说明</td>
										        <td colspan="5"><span name="guaranteeRemark"></span>&nbsp;</td>
									        </tr>
						    			</tbody>
						    		</table>
			    				</li>
						    </ul>
					    </form>
					</div>
			    </div>
			</div>
			<div id="tab2" class="tabson">
				<div class="formbody">
					<div class="formtitle"><span>合同签订</span></div>
			    	<div class="toolsli">
						<form id="_contract_detail" name="_contract_detail" enctype="multipart/form-data" method="post">
							<input type="hidden" name="id" id="contractId"  value=""/>
			    			<ul class="forminfo">
			    				<li>
			    					<table class="newtablelist" id="">
								        <tbody>
										    <tr>
										        <td class="newtd">合同编号</td>
										        <td colspan="5"><span name="contractCode"></span>&nbsp;（<a class="tablelink" href="javascript:void(0)" onclick="contract_loading(${param.loanId},${param.clientId})">上传合同</a>）</td>
									        </tr>
									        <tr>
										        <td class="newtd">合同日期</td>
										        <td><span name="contractDate@[yyyy-MM-dd]"></span>&nbsp;</td>
										        <td class="newtd">合同期限（月）</td>
										        <td colspan="3"><span name="contractDeadline"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">地址</td>
										        <td colspan="5"><span name="contractAddress"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">备注</td>
										        <td colspan="5"><span name="contractRemark"></span>&nbsp;</td>
									        </tr>
									        <tr>
										        <td class="newtd">合同签订备注</td>
										        <td colspan="5"><textarea class="textinput easyui-validatebox" id="contractAuditRemark" name="contractAuditRemark" style="margin-top: 10px;width: 600px;"></textarea></td>
									        </tr>
									 	</tbody>
									</table>
						    	</li>
				   				<li>
									<label>&nbsp;</label>
									
									<input  type="button" class="scbtn" value="签订合同" onclick="signContract();" />&nbsp;&nbsp;&nbsp;&nbsp;
									<input  type="button" class="scbtn" value="退回审批" onclick="rebackToApproval();" />&nbsp;&nbsp;&nbsp;&nbsp;
									<input  type="button" class="scbtn" value="退回合同" onclick="backToloanContract();" />&nbsp;&nbsp;&nbsp;&nbsp;
									<input  type="button" class="scbtn" value="返回" onclick="history.go(-1);"/>
								</li>
			  	 			</ul>
			   			</form>
				    </div>
				</div>
			</div>
			
    	</div>

    </div>
    
	
	
    
</body>
</html>
